//
//  ViewController.m
//  图片游览器
//
//  Created by 宋 on 16/3/3.
//  Copyright © 2016年 宋. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"girl.jpg"]];
    
    
    self.myScrollView.contentSize = CGSizeMake(1000, 600);
    self.myScrollView.showsHorizontalScrollIndicator = NO;
    self.myScrollView.showsVerticalScrollIndicator = NO;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (IBAction)sroll1 {
    CGPoint imageOffset = self.myScrollView.contentOffset;
    
    CGFloat offsetx = imageOffset.x;
    CGFloat offsety = imageOffset.y - 20;
    CGPoint offset = CGPointMake(offsetx, offsety);
    [self.myScrollView setContentOffset:offset animated:YES];
   // self.myScrollView.contentOffset = CGPointMake(offsetx, offsety);
}

- (IBAction)sroll {
    CGPoint imageOffset = self.myScrollView.contentOffset;
    
    CGFloat offsetx = imageOffset.x;
    CGFloat offsety = imageOffset.y + 20;
    
    CGPoint offset = CGPointMake(offsetx, offsety);
    [self.myScrollView setContentOffset:offset animated:YES];
    //self.myScrollView.contentOffset = CGPointMake(offsetx, offsety);
    
}

- (IBAction)up {
    NSString *imagename = [[NSString alloc] init];
    NSString *myimage = self.imageId.text;
    NSString *idofstr = [myimage substringToIndex:2];
    int idofint = [idofstr intValue];
    if (idofint == 1) {
        UIAlertView *msg = [[UIAlertView alloc] initWithTitle:@"提示" message:@"当前为第一张" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [msg show];
    }else{
        idofint --;
        if (idofint<10) {
            idofstr = [NSString stringWithFormat:@"0%d/24",idofint];
        }
        else{
            idofstr = [NSString stringWithFormat:@"%d/24",idofint];
        }
        imagename = [NSString stringWithFormat:@"%d.jpg",idofint];
        
        self.imageId.text = idofstr;
        self.ImageView.image = [UIImage imageNamed:imagename];
        
    }
}

- (IBAction)down {
    NSString *imagename = [[NSString alloc] init];
    NSString *myimage = self.imageId.text;
    NSString *idofstr = [myimage substringToIndex:2];
    int idofint = [idofstr intValue];
    if (idofint == 24) {
        UIAlertView *msg = [[UIAlertView alloc] initWithTitle:@"提示" message:@"当前为最后一张" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [msg show];
    }else{
        idofint ++;
        if (idofint<10) {
            idofstr = [NSString stringWithFormat:@"0%d/24",idofint];
        }
        else{
            idofstr = [NSString stringWithFormat:@"%d/24",idofint];
        }
        imagename = [NSString stringWithFormat:@"%d.jpg",idofint];
        
        self.imageId.text = idofstr;
        self.ImageView.image = [UIImage imageNamed:imagename];
    }

}
    
    @end
